package com.study.leetcode;

public class Solution_69 {
    public static int mySqrt(int x) {
        if (x == 1) {
            return x;
        }
        int min = 0;
        int max = x;
        while (max - min > 1) {

            int mid = (min + max) / 2;
            //如果 m*m < x则min扩大
            if (x / mid < mid) {
                //反之max缩小
                max = mid;
            } else {
                min = mid;
            }
        }
        return min;
    }
}
